<?php
namespace app\manage\model;

use think\Model;
use think\Session;

class Indent extends Model
{
    public static function getIndents()
    {
        $Tid=Session::get('userid');
        $re=self::alias('a')
            ->join('agency b','a.agencyid=b.id','LEFT')
            ->join('issue c','a.issueid=c.id','LEFT')
            ->join('user d','a.userid=d.id','LEFT')
            ->join('pushwater e','a.id=e.indentid','LEFT')
            ->where('b.manageid',$Tid)
            ->where('a.audit',4)
            ->field('a.*,b.shop as agency,c.name as issue,d.name as user,e.managepush as royalty')
            ->order('a.uptimes desc')
            ->select();
        return $re;
    }
    public static function getIndentsnum($Tid){
        $num=self::alias('a')
            ->join('agency b','a.agencyid=b.id','LEFT')
            ->join('pushwater e','a.id=e.indentid','LEFT')
            ->where('b.manageid',$Tid)
            ->where('a.audit',4)
            ->count();
        return $num;
    }
}
?>